package com.findviewbydream.evil.eda.Utils.Dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.view.View;

import com.flyco.animation.ZoomEnter.ZoomInEnter;
import com.flyco.animation.ZoomExit.ZoomInExit;
import com.flyco.dialog.listener.OnBtnClickL;
import com.flyco.dialog.widget.MaterialDialog;

/********************************************
 * 工程名：Eda
 * 包名：com.findviewbydream.evil.eda.Utils.Dialog
 * 时间：16-8-30 下午7:54
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：
 ********************************************/
public class CustomMaterialDialog
{
    private NMaterialDialog dialog;

    public CustomMaterialDialog(Context context)
    {
        dialog = new NMaterialDialog(context);
        dialog.showAnim(new ZoomInEnter());
        dialog.dismissAnim(new ZoomInExit());
        dialog.isTitleShow(false);
    }

    public CustomMaterialDialog setTitle(String title)
    {
        dialog.isTitleShow(true);
        dialog.title(title);
        return this;
    }

    public CustomMaterialDialog setMessage(String msg)
    {
        dialog.content(msg);
        return this;
    }

    public CustomMaterialDialog setContentView(View view)
    {
        dialog.setContentView(view);
        return this;
    }

    public CustomMaterialDialog setButtonText(String... buttonText)
    {
        dialog.btnText(buttonText);
        return this;
    }

    public CustomMaterialDialog setButtonOnClick(OnBtnClickL... btnClickLs)
    {
        dialog.btnNum(btnClickLs.length);
        dialog.setOnBtnClickL(btnClickLs);
        return this;
    }

    public CustomMaterialDialog setCanBack(boolean isCanBack)
    {
        dialog.setCancelable(isCanBack);
        dialog.setCanceledOnTouchOutside(isCanBack);
        return this;
    }

    public CustomMaterialDialog setOnDismissListener(DialogInterface.OnDismissListener listener)
    {
        dialog.setOnDismissListener(listener);
        return this;
    }

    public void show()
    {
        dialog.show();
    }


    public void dismiss()
    {
        if (dialog.isShowing())
            dialog.dismiss();
    }

    public boolean isShowing()
    {
        return dialog.isShowing();
    }
}
